package com.chujian.Activities;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.chujian.Threads.HttpClientPostThread;
import com.chujian.Utils.Constan;
import com.chujian.orderingsystem.R;

public class AddCategaryDialog extends Activity {
	private EditText mEtCategary;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏  
		setContentView(R.layout.add_categary);
		mEtCategary=(EditText) findViewById(R.id.et_ac_new_categary);
		
	}
	public void doClick(View v){
		switch (v.getId()) {
		case R.id.btn_ac_cancel:
			AddCategaryDialog.this.finish();
			break;
		case R.id.btn_ac_confirm:
			String str=mEtCategary.getText().toString();
			if(str.equals("")){
				Toast.makeText(AddCategaryDialog.this, "类别名称不能为空", Toast.LENGTH_SHORT).show();
				break;
			}
			confirmDialog(str);
			break;

		default:
			break;
		}
		
	}
	private void confirmDialog(final String newCategary) {
        AlertDialog.Builder builder = new AlertDialog.Builder(AddCategaryDialog.this);
        builder.setTitle("");
        builder.setMessage("添加新的类别需要为该类别添加菜品，继续吗？");
        builder.setPositiveButton("继续", new DialogInterface.OnClickListener(){
            @Override
            public void onClick(DialogInterface dialog, int which){
            	Intent intent =new Intent(AddCategaryDialog.this, AddFoodActivity.class);
            	intent.putExtra("foodCategary", newCategary);
            	startActivity(intent);
            	AddCategaryDialog.this.finish();
            }
        });
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener(){
            @Override
            public void onClick(DialogInterface dialog, int which){
            	AddCategaryDialog.this.finish();
            }
        });
        builder.show();
	}
}
;
